package wan.moneybook.sql;

import java.io.Reader;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class SqlMapper {
	private static SqlMapClient sqlMap;

	static {
		try {
			String resource = "wan/moneybook/sql/sqlmap-config.xml";
			Reader reader = Resources.getResourceAsReader(resource);
			SqlMapper.sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		} catch (Exception e) {
			throw new RuntimeException("Error initializing SqlMapConfig class. Cause:" + e);
		}
	}

	public static SqlMapClient getInstance() {
		return SqlMapper.sqlMap;
	}
}